Skip to content

Comments

Vector algorithms: Add compile time checks for ISA features#6098

Open
matbech wants to merge 2 commits intomicrosoft:mainfrom
matbech:patch-1
Open

Vector algorithms: Add compile time checks for ISA features#6098
matbech wants to merge 2 commits intomicrosoft:mainfrom
matbech:patch-1

Conversation

@matbech
Copy link
Contributor

@matbech matbech commented Feb 22, 2026

When the STL is compiled with /arch:SSE4.2 or /arch:AVX2, the runtime checks for the respective ISA features (SSE42, AVX2) are unnecessary. This change adds a compile time check using __check_arch_support to avoid the runtime cost.

When the STL is compiled with /arch:SSE4.2 or /arch:AVX2, the runtime checks for the respective ISA features (SSE42, AVX2) are unnecessary. This change adds a compile time check using __check_arch_support to avoid the runtime cost.
@matbech matbech requested a review from a team as a code owner February 22, 2026 02:23
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Feb 22, 2026
@AlexGuteniev
Copy link
Contributor

But what is the purpose?

For end users, the STL comes precompiled, so /arch flag passed by users, only affects public headers, but not separately compiled code. And when it is compiled for shipping it is always the same /arch option, which is SSE2 for x86, and baseline for x64.

@matbech
Copy link
Contributor Author

matbech commented Feb 22, 2026

For custom built binaries (msvcp140_oss.dll) with modern /arch compiler flags where performance is important.

@StephanTLavavej
Copy link
Member

For reference, __check_arch_support:

The __check_arch_support intrinsic can always be evaluated at compile time, so using it in optimized code adds no extra instructions to execute. Support for these intrinsics was added in Visual Studio 2022 version 17.10.

@StephanTLavavej StephanTLavavej added the performance Must go faster label Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

3 participants